package com.atguigu.boot.config;

import com.atguigu.boot.bean.Pet;
import com.atguigu.boot.bean.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWarDeployment;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = true)
public class MyConfig {

    @ConditionalOnBean(name = "tom")//容器中有 Tom组件  才执行 添加user01组件
    @Bean
    public User user01(){
        return new User("zs",18);
    }

    @Bean
    public Pet tomcatPet(){
        return new Pet("tomcat");
    }
}
